<?php
session_start();
include 'interface.php';
include 'dbconnect.php';
$dbcnx = dbconnect();

include 'comments_table.php';



$id = $_GET['id'];
$query = sprintf("SELECT record.*, user.name 
				FROM records record, users user
				WHERE record.id = %d AND record.author_id = user.id", $id);
$news = mysql_query($query);


echo "<title>";
  echo mysql_result($news, 0, 'caption');
echo "</title>";
echo "<html>";
    echo "<table width = \"100%\" bordercolor = \"green\">";
      drawHeader();
    echo "<tr>";
      echo "<td></td>";
      echo "<th colspan = \"2\">";
        echo "<table width = \"100%\" bordercolor = \"green\">";
        
          echo "<tr><td></td><td></td><td></td></tr>";
          echo "<tr><th colspan = \"3\" bgcolor = \"white\" align = \"center\"><font size = \"7\" color = \"black\">";
          echo mysql_result($news, 0, 'caption');
          echo "</font></th></tr>";
          
          echo "<tr><th colspan = \"3\" align = \"justify\">";
          echo mysql_result($news, 0, 'text');
          echo "</th></tr>";
          
          echo "<tr><td align = \"left\">";
          echo mysql_result($news, $i, 'name');
          echo "</td><td>&nbsp</td><td align = \"right\">";
          echo mysql_result($news, $i, 'date');
          echo "</td></tr>";
          
        echo "</table>";
      echo "</th>";
      
      echo "<td valign = \"top\">";
	  if ($_SESSION['loggedIn'])
	  {
        echo "<table width = \"100%\" bordercolor = \"red\">";
          echo "<tr>";
            echo "<td align = \"center\">";
              echo "<p>";
                echo "<b>";
				
				
				echo "<a href = request.php>";
				
				echo "Оставить заявку!</b>";
              echo "</p>";
            echo "</td>";
          echo "</tr>";
        echo "</table>";
		}
      echo "</td>";
    echo "</tr>";
    
    echo "<tr  cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"white\"><th colspan = \"2\">&nbsp;</th></tr>";
    
    echo "<tr><td></td><td><font size = \"4\"><u><b style=\"background:#FFFFCC\">Комментарии:</b></u></font></td></tr>";
    
    echo "<tr>";
    echo "<td></td>";
    echo "<th colspan = \"2\">";
      drawCommentsTable($id);
    echo "</th>";  
    echo "</tr>";
    echo "<tr><th colspan = \"3\">";
    if ($_SESSION['loggedIn'])
	{
    $ref = sprintf("comment.php?news_id=%d", $id);
    echo "<a href = ";
    echo $ref;
    echo ">";
	echo "Комментировать!";
	}
    
    
    echo "</a></th></tr>";
    
  echo "</table>";
echo "</html>";
?>